import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.stream.Stream;

public class JunitTest {





    @Test
    public void Test01(){
        System.out.println("则是JunitTest里面的test01方法");
    }

    @Test
    public void Test02(){
        System.out.println("则是JunitTest里面的test02方法");
    }

    @Disabled
    public void Test03(){
        WebDriver webDriver = new ChromeDriver();
        webDriver.get("https://www.baidu.com/");
        webDriver.findElement(By.cssSelector("#s-top-left > a:nth-child(6)"));
    }

//    @BeforeAll
//    public static void SetUp(){
//        System.out.println("这是BeforeAll里面的语句");
//    }
//
//    @AfterAll
//    public static void TearDown(){
//        System.out.println("这是AfterAll里面的语句");
//    }

//    @BeforeEach
//    public void BeforeEachTest(){
//        System.out.println("beforeEach");
//    }
//
//
//    @AfterEach
//    public void AfterEachTest(){
//        System.out.println("afterEach");
//    }


    //单参数
    @ParameterizedTest
    @ValueSource(ints = {1,2,3})
    void Test04(int num){
        System.out.println(num);
    }

    @ParameterizedTest
    @ValueSource(strings =  {"1","2","3"})
    void Test05(String number){
        System.out.println(number);
    }


    //CSV    csv文件里一行是一个数据
    @ParameterizedTest
    @CsvFileSource(resources = "test01.csv")
    void Test06(String name1){
        System.out.println(name1);
    }



    public static Stream<Arguments> Generator() {
        return Stream.of(Arguments.arguments(1,"张三"),
                Arguments.arguments(2,"李四"),
                Arguments.arguments(3,"王五"));
    }
    @ParameterizedTest
    @MethodSource("Generator")
    void Test07(int num,String name){
        System.out.println(num+": "+name);
    }





}
